﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DAL
{
    public class CompanyGroup
    {
        public static bool Insert(string groupName)
        {
            return DbHelper.ExecuteNonQuery("[dbo].[p_CompanyGroup_insert]", groupName);
        }

        public static bool update(int cgid,int groupId,string groupName)
        {
            return DbHelper.ExecuteNonQuery("[dbo].[p_CompanyGroup_update]", cgid, groupId,groupName);
        }

        public static bool delete(int cgid)
        {
            return DbHelper.ExecuteNonQuery("[dbo].[p_CompanyGroup_delete]", cgid);
        }

        public static DataSet select(string where,string orderBy,int pageSize,int pageIndex)
        {
            return DbHelper.ExecuteDataSetPageSize("*", "[dbo].[vw_CompanyGroup_list]", where, "cgid", orderBy, pageSize, pageIndex);
        }

        public static DataTable listAll()
        {
            return DbHelper.ExecuteSqlDataTable("select groupId,groupName from [dbo].[companyGroup]");
        }

        public static bool insertUpdateRelation(int curCompanyId, int curGroupId, int newGroupId)
        {
            return DbHelper.ExecuteNonQuery("[dbo].[p_CompanyGroupRelation_insertUpdate]", curCompanyId, curGroupId, newGroupId);
        }

        public static DataTable listGroupByCompanyId(int companyId)
        {
            return DbHelper.ExecuteDataTable("[dbo].[p_CompanyGroup_listGroupByCompanyId]", companyId);   
        }
    }
}
